<div id="danhmuc-header">
    DANH MỤC SẢN PHẨM
</div>
<div id='danhmuc-content'>
    <ul>
        <?php
        $sql="SELECT * FROM tbl_danhmuc";
        $res=mysql_query($sql);
        while($row=mysql_fetch_array($res))
        {
        ?>
            <li class='has-sub'><a href='index.php?page=san-pham&list=danh-muc&item=<?php echo $row['danhmuc_id']?>'><span><?php echo $row['danhmuc']?></span></a>
                <ul>
                    <?php
                    $sql_cl="SELECT * FROM tbl_chungloai WHERE danhmuc_id='".$row['danhmuc_id']."'";
                    $res_cl=mysql_query($sql_cl);
                    while($row_cl=mysql_fetch_array($res_cl))
                    {
                    ?>
                    <li class='has-sub'><a href='index.php?page=san-pham&list=chung-loai&cate=<?php echo $row_cl['chungloai_id']?>'><span><?php echo $row_cl['chungloai']?></span></a>
                        <?php
                        $sql_l="SELECT * FROM tbl_loai WHERE chungloai_id='".$row_cl['chungloai_id']."'";
                        $res_l=mysql_query($sql_l);
                        $num=mysql_num_rows($res_l);
                        if($num>0)
                        {
                            ?>
                            <ul>
                                <?php
                                while($row_l=mysql_fetch_array($res_l))
                                {
                                ?>
                                <li><a href='index.php?page=san-pham&list=loai&kind=<?php echo $row_l['loai_id']?>'><span><?php echo $row_l['loai']?></span></a></li>
                                <?php
                                }
                                ?>
                            </ul>
                            <?php
                        }
                        ?>
                    </li>
                    <?php
                    }
                    ?>
                </ul>
            </li>
        <?php
        }
        ?>

    </ul>
</div>